package com.eascs.web.p2p.member.untils;

import java.util.regex.Pattern;

import org.apache.commons.lang3.StringUtils;

public final class BankCardUtils {
	/**
	 * 银行卡格式校验
	 */
    private static final Pattern BANKCARD_PATTERN = Pattern.compile("^(\\d{12}(?:\\d{4,7})?)$");
    
    /**
     * 验证是否合法的银行卡号
     * @param cardNum
     * @return
     * @create_time 2014-05-29 下午01:56:01
     */
    public static boolean validCardNum(String cardNum){
    	return BANKCARD_PATTERN.matcher(StringUtils.trimToEmpty(cardNum)).matches();
    }
    
    /**
     * 银行卡信息屏蔽
     * @param cardNum
     * @return
     */
    public static String closedCardNum(String cardNum) {
    	if(StringUtils.isBlank(cardNum) || cardNum.length() < 8){
    		return cardNum;
    	} 
    	 return cardNum.substring(cardNum.length() -  4, cardNum.length());    	
    }
    
}
